<script type="">

    $(function() {
        $('#start_date,#end_date').datepicker({
            changeYear: true,
            dateFormat:'dd/mm/yy',                                    
            showOn:'both',           
            buttonImage: '<?=Yii::app()->params["urlRs"]."/images/calendar.png"?>',
            buttonImageOnly: 'true'
        });   

        $(".ui-datepicker-trigger").css("margin-bottom","-5px");
        $(".ui-datepicker-trigger").css("margin-left","5px"); 
    });

    function update_task(task_id){        
        var category_id = $('#category_id').val();
        var task_name = $('#task_name').val();
        var task_description = $('#task_description').val();
        var task_status = $('#task_status').val();
        var task_priority = $('#task_priority').val();
        var assign_user_id = $('#assign_user_id').val();
        var task_version = $('#task_version').val();
        var start_date = $('#start_date').val();
        var end_date = $('#end_date').val();
        var task_estimated_time = $('#task_estimated_time').val();
        var task_percent_done = $('#task_percent_done').val();
        assign_user_id = assign_user_id.toString();       
        
        /*var selected = new Array();
        $('#watchers_form input:checked').each(function() {            
            selected.push($(this).val());
        });
        selected = selected.toString();                */
        
        if(task_name == ''){
            alert('Bạn chưa nhập tên công việc!');
            return false;
        }
        
        if(assign_user_id == ''){
            alert('Bạn chưa chọn nhân viên!');
            return false;
        }

        var strUrl = '<?=$url->createUrl("task/ajaxUpdateTask") ?>';            
        loadingAjax();
        $.ajax({
            type: "GET",
            url: strUrl,
            data: {task_id:task_id,category_id:category_id,task_name:task_name,task_description:task_description,task_status:task_status,task_priority:task_priority,
            assign_user_id:assign_user_id,task_version:task_version,start_date:start_date,end_date:end_date,task_estimated_time:task_estimated_time,task_percent_done:task_percent_done},
            success: function(msg){                            
                if(msg==1){                       
                    alert('Sửa công việc thành công');
                    //location.reload();   
                }
            }
        });

        closeLoadingAjax();

    }

</script>